atspiroot: Implement GetLocale
authorMatthias Clasen <mclasen@redhat.com>
Fri, 9 Oct 2020 19:16:43 +0000 (15:16 -0400)
committerEmmanuele Bassi <ebassi@gnome.org>
Mon, 12 Oct 2020 15:19:32 +0000 (16:19 +0100)
gtk/a11y/gtkatspiroot.c

index 998ef9513463f736872bbdc46ea0b1419641b5ae..3f64ebf82c544cd125694434ec82169ebc1947cd 100644 (file)
@@ -137,7 +137,6 @@ gtk_at_spi_root_get_property (GObject    *gobject,
     }
 }
 
-
 static void
 handle_application_method (GDBusConnection       *connection,
                            const gchar           *sender,
@@ -148,6 +147,28 @@ handle_application_method (GDBusConnection       *connection,
                            GDBusMethodInvocation *invocation,
                            gpointer               user_data)
 {
+  if (g_strcmp0 (method_name, "GetLocale") == 0)
+    {
+      guint lctype;
+      const char *locale;
+
+      int types[] = {
+        LC_MESSAGES, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME
+      };
+
+      g_variant_get (parameters, "(u)", &lctype);
+      if (lctype >= G_N_ELEMENTS (types))
+        {
+          g_dbus_method_invocation_return_error (invocation,
+                                                 G_IO_ERROR,
+                                                 G_IO_ERROR_INVALID_ARGUMENT,
+                                                 "Not a known locale facet: %u", lctype);
+          return;
+        }
+
+      locale = setlocale (types[lctype], NULL);
+      g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", locale));
+    }
 }
 
 static GVariant *